package com.stars.easyms.rest.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.Set;

/**
 * EasyMs的REST属性类型
 *
 * @author guoguifang
 * @date 2018-10-12 11:24
 * @since 1.0.0
 */
@ConfigurationProperties(prefix = EasyMsRestProperties.REST_PREFIX)
public class EasyMsRestProperties {

    public static final String REST_PREFIX = "spring.rest";

    /**
     * Whether to activate, default true
     */
    private boolean enabled = true;

    /**
     * Scanning Package Path, multiple split using ','
     */
    private Set<String> basePackage;

    /**
     * URL pattern for rest filter, default is /*
     */
    private Set<String> urlPatterns;

    /**
     * Duplicate request removal is or not enabled, default true
     */
    private boolean duplicateRemovalEnabled = true;

    /**
     * Rest filter chain order.
     */
    private int order = 0;

    /**
     * Whether default use FastJsonHttpMessageConverter.
     */
    private boolean fastJson = true;

    /**
     * Whether global encrypt, value default false
     */
    private boolean encrypt;

    /**
     * Global secret key, if null default not encrypted
     */
    private String secret;

    /**
     * Global secret iv, if null default not encrypted
     */
    private String iv;

    /**
     * Global encryption request parameters
     */
    private String encryptRequestKey;

    /**
     * Global encryption response parameters
     */
    private String encryptResponseKey;

    /**
     * Whether allow end is forward slash '/', value default false
     */
    private boolean allowEndIsForwardSlash;

    /**
     * UserInfo information for JWT transfer
     */
    private String userInfoClass;

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public Set<String> getBasePackage() {
        return basePackage;
    }

    public void setBasePackage(Set<String> basePackage) {
        this.basePackage = basePackage;
    }

    public Set<String> getUrlPatterns() {
        return urlPatterns;
    }

    public void setUrlPatterns(Set<String> urlPatterns) {
        this.urlPatterns = urlPatterns;
    }

    public boolean isDuplicateRemovalEnabled() {
        return enabled && duplicateRemovalEnabled;
    }

    public void setDuplicateRemovalEnabled(boolean duplicateRemovalEnabled) {
        this.duplicateRemovalEnabled = duplicateRemovalEnabled;
    }

    public int getOrder() {
        return order;
    }

    public void setOrder(int order) {
        this.order = order;
    }

    public boolean isFastJson() {
        return fastJson;
    }

    public void setFastJson(boolean fastJson) {
        this.fastJson = fastJson;
    }

    public boolean isEncrypt() {
        return encrypt;
    }

    public void setEncrypt(boolean encrypt) {
        this.encrypt = encrypt;
    }

    public String getSecret() {
        return secret;
    }

    public void setSecret(String secret) {
        this.secret = secret;
    }

    public String getIv() {
        return iv;
    }

    public void setIv(String iv) {
        this.iv = iv;
    }

    public String getEncryptRequestKey() {
        return encryptRequestKey;
    }

    public void setEncryptRequestKey(String encryptRequestKey) {
        this.encryptRequestKey = encryptRequestKey;
    }

    public String getEncryptResponseKey() {
        return encryptResponseKey;
    }

    public void setEncryptResponseKey(String encryptResponseKey) {
        this.encryptResponseKey = encryptResponseKey;
    }

    public boolean isAllowEndIsForwardSlash() {
        return allowEndIsForwardSlash;
    }

    public void setAllowEndIsForwardSlash(boolean allowEndIsForwardSlash) {
        this.allowEndIsForwardSlash = allowEndIsForwardSlash;
    }

    public String getUserInfoClass() {
        return userInfoClass;
    }

    public void setUserInfoClass(String userInfoClass) {
        this.userInfoClass = userInfoClass;
    }
}
